<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>统计表</title>
    <script src="layui-v2.6.8/layui/layui.js"></script>
    <link rel="stylesheet" href="layui-v2.6.8/layui/css/layui.css">
</head>
<body>
<ul class="layui-nav">
    <li class="layui-nav-item" ><a href="qiandao.html" style="font-size: 20px">我要签到</a></li>
    <li class="layui-nav-item" ><a href="out.html" style="font-size: 20px">我要离开</a></li>
    <li class="logo" style="float: right"><a href=""><img src="img/logo.png" width="60px" height="60px"></a></li>
    <li class="layui-nav-item" style="float: right" ><a href="zuche.html" style="font-size: 20px">我要注册</a></li>
    <li class="text_center" style="float: right;margin-right: 400px;line-height: 60px;color: gray;font-size: 30px" >智能软件研发实验室</li>
    <li class="layui-nav-item" ><a href="total.html" style="font-size: 20px">签到统计</a></li>
</ul>
  <table class="layui-hide" id="test" lay-filter="test"></table>
</body>

<script>
  layui.use('table', function(){
    var table = layui.table;
    table.render({
      elem: '#test'
      ,url:'test/table/demo1.json'
      ,toolbar: '#toolbarDemo'
      ,title: '用户数据表'
      ,totalRow: true
      ,cols: [[
        {type: 'checkbox', fixed: 'left'}
        ,{field:'id', title:'学号', width:200, fixed: 'left', unresize: true, sort: true, totalRowText: '合计'}
        ,{field:'username', title:'姓名', width:200, edit: 'text'}
        ,{field:'grade', title:'年级', width:100, edit: 'text', sort: true}
        ,{field:'logins', title:'签到时间', width:200}
        ,{field:'sign', title:'离开时间',width: 200}
        ,{field:'text', title:'签到状态', width:200, edit: 'text', sort: true}
        ,{field:'times', title:'累计签到', width:200, edit: 'text', sort: true}
      ]]
      ,page: true
    });

    //工具栏事件
    table.on('toolbar(test)', function(obj){
      var checkStatus = table.checkStatus(obj.config.id);
      switch(obj.event){
        case 'getCheckData':
          var data = checkStatus.data;
          layer.alert(JSON.stringify(data));
          break;
        case 'getCheckLength':
          var data = checkStatus.data;
          layer.msg('选中了：'+ data.length + ' 个');
          break;
        case 'isAll':
          layer.msg(checkStatus.isAll ? '全选': '未全选')
          break;
      };
    });
  });
</script>
</html>